package com.kk.controller;

import com.kk.annotation.OperationLog;
import com.kk.common.PageResult;
import com.kk.common.Result;
import com.kk.enums.OperationType;
import com.kk.pojo.entity.SysRole;
import com.kk.pojo.request.RoleRequest;
import com.kk.service.SysRoleService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author kl
 * @version 1.0
 * @description: TODO
 * @date 2025/11/5 上午9:43
 */
@RestController
@RequestMapping("/roles")
@RequiredArgsConstructor
public class SysRoleController {

    private final SysRoleService sysRoleService;
    /**
     * 获取角色列表
     */
    @OperationLog(
            module = "roles",
            description = "查询角色列表",
            type = OperationType.QUERY
    )
    @GetMapping("/pages")
    @PreAuthorize("hasAuthority('system:role:list')")
    public Result<PageResult<SysRole>> rolePageController(RoleRequest request) {
        return Result.success(sysRoleService.rolePage(request));
    }
}
